#ifndef _GAME_SYSTEM_PARAMETER_H_
#define _GAME_SYSTEM_PARAMETER_H_

#include <string>
#include <map>
#include "Ogre.h"
#include "OgreStringConverter.h"

using namespace std;
using namespace Ogre;

class GameSystemParameter
{
public:

	template< typename T >
	GameSystemParameter(std::string name, shared_ptr<T> a ) {
		mObj = a;
		mName = name;
	}

	~GameSystemParameter() {	}

	template< typename T >
	bool setParam(std::string name, shared_ptr<T> a ) //Stack< T >::
	{
		mObj = a;
		mName = name;
		return true;
	}

	const std::string getName() {
		return mName;
	}

	bool setValue( std::string val )
	{
		if (shared_ptr<string>* sp = any_cast<shared_ptr<string>>(&mObj)) {
			**sp = val;
			return true;
		}
		if (shared_ptr<float>* sp = any_cast<shared_ptr<float>>(&mObj)) {
			**sp = StringConverter::parseReal(val);
			return true;
		}
		if (shared_ptr<unsigned int>* sp = any_cast<shared_ptr<unsigned int>>(&mObj)) {
			**sp = StringConverter::parseUnsignedInt(val);
			return true;
		}
		if (shared_ptr<int>* sp = any_cast<shared_ptr<int>>(&mObj)) {
			**sp = StringConverter::parseInt(val);
			return true;
		}
		if (shared_ptr<bool>* sp = any_cast<shared_ptr<bool>>(&mObj)) {
			**sp = StringConverter::parseBool(val);
			return true;
		}
		return false;
	}

	const std::string toString() {
		if( mObj.type() == typeid(shared_ptr<string>) ) {
			if (shared_ptr<string>* s = any_cast<shared_ptr<string>>(&mObj))
				return **s;
		}

		if( mObj.type() == typeid(shared_ptr<float>) ) {
			if (shared_ptr<float>* s = any_cast<shared_ptr<float>>(&mObj))
				return StringConverter::toString(**s);
		}
		if( mObj.type() == typeid(shared_ptr<int>) ) {
			if (shared_ptr<int>* s = any_cast<shared_ptr<int>>(&mObj))
				return StringConverter::toString(**s);
		}		
		if( mObj.type() == typeid(shared_ptr<unsigned int>) ) {
			if (shared_ptr<unsigned int>* s = any_cast<shared_ptr<unsigned int>>(&mObj))
				return StringConverter::toString(**s);
		}
		if( mObj.type() == typeid(shared_ptr<bool>) ) {
			if (shared_ptr<bool>* s = any_cast<shared_ptr<bool>>(&mObj))
				return StringConverter::toString(**s);
		}

		return NULL;
	}

	const float toFloat() {
		return StringConverter::parseReal(toString());
	}
	const int toInt() {
		return StringConverter::parseInt(toString());
	}
	const unsigned int toUInt() {
		return StringConverter::parseUnsignedInt(toString());
	}
	const bool toBool() {
		return StringConverter::parseBool(toString());
	}

private:
	boost::any mObj;

	std::string mName;
};
#endif